package com.jushu.storbox;

import java.util.Date;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;

import com.jushu.storbox.constant.ClientConfig;


/**
 * cloud drive base activity
 * 
 */
public class BaseActivity extends Activity implements OnClickListener 
{
	/**
	 * onCreate in BaseActivity
	 * 
	 * @param savedInstanceState
	 *            Bundle
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
	}
	/**
	 * BaseActivity onClick
	 * 
	 * @param v
	 *            View
	 */
	@Override
	public void onClick(View v) 
	{

	}
	@Override
	protected void onResume() 
	{
		// TODO Auto-generated method stub
		super.onResume();
//		PublicTools.checkIsRootAndNotify(this);
	}
	@Override
	protected void onRestart() {
		// TODO Auto-generated method stub
//		   Date now = new Date();
//		   long l=now.getTime()-ClientConfig.LOACK_DATA.getTime();
//		   long day=l/(24*60*60*1000);
//		   long hour=(l/(60*60*1000)-day*24);
//		   long min=((l/(60*1000))-day*24*60-hour*60);
//		   long s=(l/1000-day*24*60*60-hour*60*60-min*60);
//		   if((int)s>5) 
//		   {
//			   Intent intent = new Intent(getApplicationContext(), LoackaActivity.class);
//			   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//			   getApplicationContext().startActivity(intent);
//		   }
		   super.onRestart();
	}
	private boolean getLoackStruts()
	{
		SharedPreferences settings = getApplicationContext().getSharedPreferences(ClientConfig.settings, Context.MODE_APPEND);
		return settings.getBoolean(ClientConfig.AUTO_SAFETY_LOCK, false);
	}
	@Override
	protected void onPause() {
		ClientConfig.LOACK_DATA = null;
		ClientConfig.LOACK_DATA = new Date();
		super.onPause();
	}

}
